package com.example.devicemanage.dao;

import com.example.devicemanage.entity.Regist;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RegisterMapper {

    @Select("SELECT * FROM regist")
    List<Regist> queryAllRegist();

    @Select("SELECT * FROM regist WHERE rid=#{rid}")
    Regist querySingleRegist(int rid);

    @Delete("DELETE FROM regist WHERE rid=#{rid}")
    int deleteRegist(int rid);

    @Insert("insert into regist(category,ename,eid,model,spec,price,num,pdate,manufacturer,slife,agent) value(#{category},#{ename},#{eid},#{model},#{spec},#{price},#{num},#{pdate},#{manufacturer},#{slife},#{agent})")
    @Options(useGeneratedKeys = true, keyProperty = "rid", keyColumn = "rid")
    int saveRegist(Regist regist);

    @Insert("insert into regist(rid,category,ename,eid,model,spec,price,num,pdate,manufacturer,slife,agent) value(#{rid},#{category},#{ename},#{eid},#{model},#{spec},#{price},#{num},#{pdate},#{manufacturer},#{slife},#{agent})")
    int updateRegist(Regist regist);
}
